package com.shuwen.gcdj.common.enums;

import com.shuwen.gcdj.bean.common.response.IntegerStringKvItemResp;

import java.util.ArrayList;
import java.util.List;

/**
 * 信息范围枚举
 */
public enum DataLevelEnum {
    DATA_LEVEL_ALL(1, "全部"),
    DATA_LEVEL_ONLY_DEPT_AND_SUB_DEPT(2, "仅本报部门及子部门"),
    DATA_LEVEL_ONLY_CREATOR_SELF(4, "仅自己"),
    DATA_LEVEL_SELECT_DEPT(8, "指定部门");

    private final Integer dataLevel;

    private final String levelName;

    DataLevelEnum(Integer dataLevel, String levelName) {
        this.dataLevel = dataLevel;
        this.levelName = levelName;
    }

    public String getLevelName() {
        return this.levelName;
    }

    public Integer getDataLevel() {
        return this.dataLevel;
    }

    public static List<IntegerStringKvItemResp> getKvMap(DataLevelEnum... levels) {
        List<IntegerStringKvItemResp> res = new ArrayList<>(levels.length);
        for (DataLevelEnum level : levels) {
            IntegerStringKvItemResp kv = new IntegerStringKvItemResp();
            kv.setKey(level.getDataLevel());
            kv.setValue(level.getLevelName());
            res.add(kv);
        }
        return res;
    }
}
